// base配置
const baseConfig = {
  publicPath: process.env.VUE_APP_BASE_URL,
};

// 开发配置
const devConfig = Object.assign({}, baseConfig, {
  devServer: {
    proxy: {
      [process.env.VUE_APP_BACK_END_API_PX_URL]: {
        target: process.env.VUE_APP_API_PROXY_URL,
        changeOrigin: true,
        pathRewrite: {
          ["^" + process.env.VUE_APP_BACK_END_API_PX_URL]: "/",
        },
      },
    },
    port: 8089,
    open: true,
  },
  // 配置pc端适配
  css: {
    loaderOptions: {
      postcss: {
        postcssOptions: {
          plugins: [
            require("postcss-pxtorem")({
              rootValue: 16, // 换算的基数
              minPixelValue: 2,
              selectorBlackList: [], // 忽略转换正则匹配项 列入一些ui库, ['.el'] 就是忽略elementUI库
              propList: ["*"],
            }),
          ],
        },
      },
    },
  },
  
});

// 生产配置
const proConfig = Object.assign({}, baseConfig, {
  outputDir: process.env.VUE_APP_OUTPUT_DIR,
  productionSourceMap: false,
  // 配置pc端适配
  css: {
    sourceMap: false,
    loaderOptions: {
      postcss: {
        postcssOptions: {
          plugins: [
            require("postcss-pxtorem")({
              rootValue: 16, // 换算的基数
              minPixelValue: 2,
              selectorBlackList: [], // 忽略转换正则匹配项 列入一些ui库, ['.el'] 就是忽略elementUI库
              propList: ["*"],
            }),
          ],
        },
      },
    },
  },
});

module.exports = process.env.NODE_ENV === "development" ? devConfig : proConfig;
